﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class ForStatementElement : StatementElement
    {
        private VariableExpressionElement iterator;
        private TokenInfo type;
        private ExpressionElement start;
        private ExpressionElement end;
        private StatementElement statement;

        public VariableExpressionElement Iterator { get { return iterator; } set { iterator = value; } }
        public TokenInfo Type { get { return type; } set { type = value; } }
        public ExpressionElement Start { get { return start; } set { start = value; } }
        public ExpressionElement End { get { return end; } set { end = value; } }
        public StatementElement Statement { get { return statement; } set { statement = value; } }

        public ForStatementElement(TokenInfo StartInfo, VariableExpressionElement Iterator, TokenInfo Type, ExpressionElement Start, ExpressionElement End, StatementElement Statement, List<TokenInfo> Comments)
            : base(StartInfo, Comments)
        {
            iterator = Iterator;
            type = Type;
            start = Start;
            end = End;
            statement = Statement;
        }

        public override string ToString()
        {
            return string.Format("for {0} := {1} {2} {3} do {4}", iterator, start, type.Text, end, statement);
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            yield return iterator;
            yield return start;
            yield return end;
            yield return statement;
        }
    }
}
